$(function () {
    getServiceTypeFindAll();
});

function getServiceTypeFindAll() {
    let result =myAjax('/back/serviceType/findType','get',{token:$.cookie("token")});
    data = result.list;
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += '<option value="' + data[i].id + '">' + data[i].serviceType + '</option>';
    }
    $("#roomType").html(html);//将页面格式加载到页面布局
}

/*文件取值  包含图片 全部转换为文件*/
function roomAdd() {
    let forData = new FormData();
    forData.append("roomId",$("#roomId").val());
    forData.append("roomType",$("#roomType").val());
    forData.append("roomType",$("#roomType option:selected").text());
    forData.append("roomPrice",$("#roomPrice").val());
    forData.append("roomTitle",$("#roomTitle").val());
    forData.append("roomPhoto", $("#roomPhoto")[0].files[0]);//文件取值
    forData.append("roomIntroduce",$("#roomIntroduce").val());
    forData.append("token",$.cookie("token"));
    let result = imgMyAjax('/back/room/roomAdd','post',forData);
    if (result.result=== 1) {
        alert("提交成功");
        $("#right").load('../back/room/roomList.html');
    } else {
        alert("提交失败")
    }
}
function flushAdd() {
    $("#right").load('../back/room/roomAdd.html');
}